//
//  StatusCellBottomView.swift
//  weibo
//
//  Created by 谭仁川 on 15/12/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {
    @objc private func retweetedBtnDidClick(){
        
        let temp = TempViewController()
        
        
        retweetedBtn.navController()?.pushViewController(temp, animated: true)
        
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        self.backgroundColor = UIColor(white: 0.98, alpha: 3)
    
        addSubview(retweetedBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)
        
        //设置布局
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.top.bottom.equalTo(self)
            
        }
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.right.equalTo(self.snp_right)
            make.width.equalTo(composeBtn.snp_width)
            make.top.bottom.equalTo(self)
        }
        let sepView1 = sepView()
        addSubview(sepView1)
        let sepView2 = sepView()
        addSubview(sepView2)
        
        let w = 0.5
        let scale = 0.4
        
        
        //设置分割线的布局
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        
        retweetedBtn.addTarget(self, action: "retweetedBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    private func sepView() -> UIView {
    
        let v = UIView()
        v.backgroundColor = UIColor.lightGrayColor()
        return v
        
    }
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), fontSize: 10, isNeedHightlighted: false, imageName: "timeline_icon_retweet")
    
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), fontSize: 10, isNeedHightlighted: false, imageName: "timeline_icon_comment")
    
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), fontSize: 10, isNeedHightlighted: false, imageName: "timeline_icon_unlike")
}
